package com.ontheroad.mysql.leanCloud.listener;

import com.ontheroad.leanCloud.event.AddUserToSessionEvent;
import com.ontheroad.leanCloud.service.LeanCloudService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

/**
 * Created by kedong on 2017/11/15 0015.
 */
@Service
public class AddUserToSessionListener implements ApplicationListener<AddUserToSessionEvent> {
    private Logger log = LoggerFactory.getLogger(getClass());

    @Autowired
    LeanCloudService leanCloudService;

    @Override
    public void onApplicationEvent(AddUserToSessionEvent event) {
        leanCloudService.addUserToSession(event.getObjectId(), event.getUserId());
    }
}
